<?php
class BudgetState extends AppModel {
	var $name = 'BudgetState';
    var $displayField = "estado";
    
	var $validate = array(
		'estado' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

/*	var $hasMany = array(
		'Budget' => array(
			'className' => 'Budget',
			'foreignKey' => 'budget_state_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	); */
    
    
    function getStateId($estado = NULL)
    {
       if( $estado == NULL)
        {
            return 0;
        }
       
       $result = $this->query("Select id from budget_states where estado = '".$estado."'");
        
       return $result[0]['budget_states']['id']; 
         
    }

}
?>